<?php
/**
 * The following variables are available in this template:
 * - $this: the BootCrudCode object
 */
?>
<?php
foreach ($this->tableSchema->columns as $column) {
	if ($column->autoIncrement) {
		continue;
	}
	$focus = $column->name;
	break;
}
echo "<?php\n";
foreach ($this->tableSchema->columns as $column) {
	if ($column->autoIncrement) {
		continue;
	}
	
	if (stripos($column->dbType, 'date') !== false) {
		echo "Yii::app()->clientScript->registerCoreScript('jquery.ui');\n\n";
		break;
	}
}
echo "\$properties = array(
	'id'=>'" . $this->class2id($this->modelClass) . "-form',
	'enableAjaxValidation'=>false,
	'focus'=>array(\$model, '$focus'),
);\n";
echo "\$form = \$this->beginWidget('bootstrap.widgets.TbActiveForm', \$properties);\n";
echo "?>\n";
?>

<p class="help-block">
	Fields with <span class="required">*</span> are required.
</p>

<?php
echo "<?php\n";
echo "echo \$form->errorSummary(\$model);\n";

$excludedColumns = array('createdAt', 'createdBy', 'updatedAt', 'updatedBy');
foreach ($this->tableSchema->columns as $column) {
	if ($column->autoIncrement) {
		continue;
	}
	echo "\n";
	echo $this->generateActiveRow($this->modelClass, $column);
	echo "\n";
}
echo "?>\n"
?>

<div class="form-actions">
	<?php
	echo "<?php\n";
	echo "\t\$properties = array(
		'buttonType'=>'submit',
		'type'=>'primary',
		'label'=>\$model->isNewRecord ? 'Create' : 'Save',
	);\n";
	echo "\t\$this->widget('bootstrap.widgets.TbButton', \$properties);\n";
	echo "\t?>\n";
	?>
</div>

<?php echo "<?php \$this->endWidget(); ?>\n"; ?>
